package paper.service;

import java.lang.reflect.InvocationTargetException;

import org.apache.commons.beanutils.PropertyUtils;
import org.apache.struts.action.ActionForm;

import paper.dao.PaperDAO;
import paper.vo.PaperVO;

public class PaperCRUDService {
	private PaperDAO pdao;
	
	public void setPdao(PaperDAO pdao){
		this.pdao = pdao;
	}
	
	public  String insertPaper(ActionForm form){
		PaperVO pvo = new PaperVO();
		System.out.println("form"+form);
		System.out.println("pvo"+pvo);
		try {
			PropertyUtils.copyProperties(pvo, form);
		} catch (IllegalAccessException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (InvocationTargetException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (NoSuchMethodException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		Object obj = pdao.insertPaper(pvo);
		if(obj!=null){
			return "fail"; 
		}else{
			return "success";
		}
	}
}
